package com.itbour.web.action.tg;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.itbour.com.page.Page;
import com.itbour.common.base.BaseAction;
import com.itbour.common.util.StringUtils;
import com.itbour.dto.com.TopicInfoDto;
import com.itbour.dto.com.UserInfoDto;
import com.itbour.dto.tg.DesignInfoDto;
import com.itbour.dto.tg.KeywordInfoDto;
import com.itbour.dto.tg.OrgInfoDto;
import com.itbour.dto.tg.TgEgretInfoDto;
import com.itbour.dto.trade.TmplPriceInfoDto;
import com.itbour.dto.video.YjxPriceInfoDto;
import com.itbour.service.tg.DesignService;
import com.opensymphony.xwork2.ActionContext;

/**
 * copyright Itbour team 2016
 * 新增 模板下架复审功能
 * @author xc 李琦
 */

public class GetDesignWebAction extends BaseAction {

	private static final long serialVersionUID = 1L;

	private DesignService designService;

	private String designId;// 设计id
	private String ids;// 删除/更新用id
	private String order;// 显示顺序
	private String price;// 设计费
	private String vip;// vip
	private String srcUrl;// 源文件
	private String chkCont;// 评审内容
	private String topType;// 顶级分类
	private String itemIdForItems;// 商品id(商品界面用)
	
	private String typeIds;// 模版类型id
	private String userId;

	private DesignInfoDto designInfo;

	private List<DesignInfoDto> designInfoList = new ArrayList<DesignInfoDto>();
	
	private TgEgretInfoDto tgEgretInfo;// 编辑器加载用数据
	
	private String findPubFlg;// 检索条件(发布状态)
	private String findTmplName;// 检索条件(模版名)
	private String findTmplType;// 检索条件(模版分类)
	private String findTmplState;// 检索条件(模版状态)
	private String findTmplId;// 检索条件(模版id)
	private String findItemId;// 检索条件(关联商品id)
	private String findVip;// 检索条件(vip)
	private String findOrg;// 检索条件(组织)
	HashMap<String, Object> mapResult = new HashMap<String, Object>();// 检索结果
	HashMap<String, Object> mapResult4Review = new HashMap<String, Object>();// 审核用检索结果
	
	HashMap<String, Object> mapResultTmplPrice = new HashMap<String, Object>();// 模版价格检索结果
	private TmplPriceInfoDto tmplPriceInfo;

	private List<OrgInfoDto> orgInfoList;// 组织信息列表
	private List<Object> keywordList;// 关键词列表
	private List<Object> topicList;// 热门专题列表
	private String stIds;// 专题id
	
	private HashMap<String, Object> userDocMap = new HashMap<String, Object>();//用户文档
	private String findDocId;//搜索文档ID
	private String findUserId;//搜索用户ID
	private String findMobile;//搜索手机号
	
	// 更新关联商品id
	public void updDesignItem() throws Exception {
		if (StringUtils.isNotBlank(designId)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	// update
	    	if(user!=null && user.getUser_id()!=null){
		    	Map<String, Object> param = new HashMap<String, Object>();
				param.put("item_id", itemIdForItems);
				param.put("design_id", designId);
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
	    	}
		}
		this.writeJSON("ok");
	}
	
	// 修改设计模版显示顺序
	public void updDesignOrder() throws Exception {
		if (StringUtils.isNotBlank(designId)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	// update
	    	if(user!=null && user.getUser_id()!=null){
		    	Map<String, Object> param = new HashMap<String, Object>();
				param.put("order", order);
				param.put("design_id", designId);
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
	    	}
		}
		this.writeJSON("ok");
	}
	
	// 修改设计模版设计费
	public void updDesignPrice() throws Exception {
		if (StringUtils.isNotBlank(designId)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	// update
	    	if(user!=null && user.getUser_id()!=null){
		    	Map<String, Object> param = new HashMap<String, Object>();
				param.put("price", price);
				param.put("design_id", designId);
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
				this.writeJSON("ok");
	    	} else {
	    		this.writeJSON("ng");
	    	}
		} else {
			this.writeJSON("ng");
		}
	}
	
	// 更新vip属性
	public void updDesignVip() throws Exception {
		if (StringUtils.isNotBlank(designId)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	// update
	    	if(user!=null && user.getUser_id()!=null){
		    	Map<String, Object> param = new HashMap<String, Object>();
				param.put("vip", vip);
				param.put("design_id", designId);
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
				this.writeJSON("ok");
	    	} else {
	    		this.writeJSON("ng");
	    	}
		} else {
			this.writeJSON("ng");
		}
	}
	
	// 更新源文件
	public void updDesignSrcUrl() throws Exception {
		if (StringUtils.isNotBlank(designId)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	// update
	    	if(user!=null && user.getUser_id()!=null){
		    	Map<String, Object> param = new HashMap<String, Object>();
				param.put("src_url", srcUrl);
				param.put("design_id", designId);
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
				this.writeJSON("ok");
	    	} else {
	    		this.writeJSON("ng");
	    	}
		} else {
			this.writeJSON("ng");
		}
	}
	
	// 取消发布
	public void cancelPublish() throws Exception {
		if (StringUtils.isNotBlank(ids)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	if(user!=null && user.getUser_id()!=null){
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("publish", 0);
				param.put("ids", StringUtils.listToString2(StringUtils.stringToList2(ids)));
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
				HttpServletRequest request = ServletActionContext.getRequest();
				String uniItemId = request.getParameter("uniItemId");
				param.put("uni_item_id", uniItemId);
				designService.delTmplSetRInfo(param);
	    	}
		}
		this.writeJSON("ok");
	}
	// 发布
	public void doPublish() throws Exception {
		// ids: ","连接
		if (StringUtils.isNotBlank(ids)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	if(user!=null && user.getUser_id()!=null){
	    		List<Long> listId = StringUtils.stringToList2(ids);
				// TODO check
				
		    	// update
	    		Map<String, Object> param = new HashMap<String, Object>();
				param.put("publish", 1);
				param.put("ids", StringUtils.listToString2(listId));
				param.put("update_by", user.getUser_id()+user.getUser_name());
				designService.updateDesignById(param);
				this.writeJSON("ok");
	    	} else {
	    		this.writeJSON("ng");
	    	}
		} else {
			this.writeJSON("ng");
		}
	}
	
	// 获取设计模版
	public String getDesign() throws Exception {

		HttpServletRequest request = ServletActionContext.getRequest();
		Map<String, Object> param = new HashMap<String, Object>();
		String id = request.getParameter("designId");
		if (StringUtils.isNotEmpty(id)) {
			param.put("design_id", id);
		}
		param.put("del_flg", 0);

		designInfoList = designService.selectDesignInfo(param);
		return SUCCESS;
	}
	
	// 获取设计模版列表
	public String getDesignInfoLst() throws Exception {
		// 用户信息
		Map<String, Object> session = ActionContext.getContext().getSession();
    	UserInfoDto user = (UserInfoDto)session.get("user");
    	if(user!=null && user.getUser_id()!=null) {
    		HttpServletRequest request = ServletActionContext.getRequest();
    		String pageNumber = request.getParameter("page");
    		String pageSize = request.getParameter("rows");
    		Map<String, Object> param = new HashMap<String, Object>();
    		if (StringUtils.isNotBlank(findTmplType) && Long.valueOf(findTmplType)>0L) {
    			param.put("type_id", findTmplType);
    		}
    		if (StringUtils.isNotBlank(findPubFlg)) {
    			param.put("publish", findPubFlg);
    		}
    		if (StringUtils.isNotEmpty(findTmplName)) {
    			param.put("design_name", "%"+findTmplName+"%");
    		}
    		if (StringUtils.isNotBlank(itemIdForItems)) {
    			param.put("itemIdForItems", itemIdForItems);
    		}
    		if (StringUtils.isNotBlank(findTmplId)) {
    			param.put("design_id", findTmplId);
    		}
    		if (StringUtils.isNotBlank(findItemId)) {
    			param.put("item_id", findItemId);
    		}
    		if (StringUtils.isNotBlank(findVip)) {
    			param.put("vip", findVip);
    		}
    		if (StringUtils.isNotBlank(findOrg) && Long.valueOf(findOrg)>0L) {
    			param.put("org_id", findOrg);
    		}

    		// 默认只检索自己的文档([管理员,模版操作员]除外)
    		if(!user.isAdmin() && (user.getRole()&32)!=32) {
    			param.put("user_id", user.getUser_id());
    		}
    		
    		Page page = designService.pageQuery(param, Integer.parseInt(pageNumber),
    				Integer.parseInt(pageSize));
    		HashMap<String, Object> resMap = new HashMap<String, Object>();
    		resMap.put("total", page.getTotalCount());
    		resMap.put("rows", page.getResult());
    		//writeJSON(resMap);
    		mapResult = resMap;
    	} else {
    		mapResult.clear();
    	}

		return SUCCESS;
	}
	
	// 获取设计模版列表(审核用)
	public String getDesignInfoLst4Review() throws Exception {
		// 用户信息
		Map<String, Object> session = ActionContext.getContext().getSession();
    	UserInfoDto user = (UserInfoDto)session.get("user");
    	if(user!=null && user.getUser_id()!=null) {
    		HttpServletRequest request = ServletActionContext.getRequest();
    		String pageNumber = request.getParameter("page");
    		String pageSize = request.getParameter("rows");
    		Map<String, Object> param = new HashMap<String, Object>();
    		if (StringUtils.isNotBlank(findTmplType) && Long.valueOf(findTmplType)>0L) {
    			param.put("type_id", findTmplType);
    		}
    		if (StringUtils.isNotBlank(findPubFlg)) {
    			param.put("publish", findPubFlg);
    		}
    		if (StringUtils.isNotBlank(findOrg) && Long.valueOf(findOrg)>0L) {
    			param.put("org_id", findOrg);
    		}
    		if (StringUtils.isNotBlank(findTmplState) && Long.valueOf(findTmplState)>0L) {
    			param.put("state", findTmplState);
    		}
    		if (StringUtils.isNotEmpty(findTmplName)) {
    			param.put("design_name", "%"+findTmplName+"%");
    		}
    		
    		Page page = designService.pageQuery(param, Integer.parseInt(pageNumber),
    				Integer.parseInt(pageSize));
    		HashMap<String, Object> resMap = new HashMap<String, Object>();
    		resMap.put("total", page.getTotalCount());
    		resMap.put("rows", page.getResult());
    		//writeJSON(resMap);
    		mapResult4Review = resMap;
    	} else {
    		mapResult4Review.clear();
    	}

		return SUCCESS;
	}
	
	/**
	 * 获取下架 	设计模板列表
	 * @return 
	 * @throws Exception
	 */
	public String getDesignInfoLstOutReview() throws Exception {
		// 用户信息
		Map<String, Object> session = ActionContext.getContext().getSession();
		UserInfoDto user = (UserInfoDto)session.get("user");
		if(user!=null && user.getUser_id()!=null) {
			HttpServletRequest request = ServletActionContext.getRequest();
			String pageNumber = request.getParameter("page");
			String pageSize = request.getParameter("rows");
			Map<String, Object> param = new HashMap<String, Object>();
			if (StringUtils.isNotBlank(findTmplType) && Long.valueOf(findTmplType)>0L) {
				param.put("type_id", findTmplType);
			}
			if (StringUtils.isNotBlank(findPubFlg)) {
				param.put("publish", findPubFlg);
			}
			if (StringUtils.isNotBlank(findOrg) && Long.valueOf(findOrg)>0L) {
				param.put("org_id", findOrg);
			}
			if (StringUtils.isNotBlank(findTmplState) && Long.valueOf(findTmplState)>0L) {
				param.put("state", findTmplState);
			}
			if (StringUtils.isNotEmpty(findTmplName)) {
				param.put("design_name", "%"+findTmplName+"%");
			}
			
			Page page = designService.pageQueryDesignOutReview(param, Integer.parseInt(pageNumber),
					Integer.parseInt(pageSize));
			HashMap<String, Object> resMap = new HashMap<String, Object>();
			resMap.put("total", page.getTotalCount());
			resMap.put("rows", page.getResult());
			if (mapResult4Review!= null){ // 如果不等于null
				mapResult.clear();// 清除数据
			}
			mapResult4Review = resMap;
		} else {
			mapResult4Review.clear();
		}
		
		return SUCCESS;
	}
	
	// 获取模版价格列表
	public String getTmplPriceInfoLst() throws Exception {
		// 用户信息
		Map<String, Object> session = ActionContext.getContext().getSession();
    	UserInfoDto user = (UserInfoDto)session.get("user");
    	if(user!=null && user.getUser_id()!=null && designId!=null && Long.valueOf(designId)>=0) {
    		HttpServletRequest request = ServletActionContext.getRequest();
    		String pageNumber = request.getParameter("page");
    		String pageSize = request.getParameter("rows");
    		Map<String, Object> param = new HashMap<String, Object>();
    		param.put("tmpl_id", designId);
    		
    		Page page = designService.pageQueryTmplPrice(param, Integer.parseInt(pageNumber),
    				Integer.parseInt(pageSize));
    		HashMap<String, Object> resMap = new HashMap<String, Object>();
    		resMap.put("total", page.getTotalCount());
    		resMap.put("rows", page.getResult());
    		//writeJSON(resMap);
    		mapResultTmplPrice = resMap;
    	} else {
    		mapResultTmplPrice.clear();
    	}

		return SUCCESS;
	}
	
	// 删除设计模版
	public void deleteDesign() throws Exception {
		Map<String, Object> session = ActionContext.getContext().getSession();
    	UserInfoDto user = (UserInfoDto)session.get("user");
    	if(user!=null && user.getUser_id()!=null) {
    		Map<String, Object> param = new HashMap<String, Object>();
    		param.put("designIds", StringUtils.listToString2(StringUtils.stringToList2(ids)));
			param.put("update_by", user.getUser_id()+user.getUser_name());
			designService.deleteDesignInfo(param);
			designService.deleteDesignPageInfo(param);
			designService.deleteDesignPCInfo(param);
    		this.writeJSON("ok");
    	} else {
    		this.writeJSON("ng");
    	}
	}
	
	// 添加模版价格
	public void addTmplPrice() throws Exception {
		Map<String, Object> session = ActionContext.getContext().getSession();
    	UserInfoDto user = (UserInfoDto)session.get("user");
		if (tmplPriceInfo != null && user != null) {
			Map<String, Object> param = new HashMap<String, Object>();
    		param.put("update_by", user.getUser_id()+user.getUser_name());
    		param.put("tmpl_id", tmplPriceInfo.getTmpl_id());
    		param.put("type", tmplPriceInfo.getType());
    		param.put("price", tmplPriceInfo.getPrice());
    		param.put("period", tmplPriceInfo.getPeriod());
    		param.put("fee", 0);// 默认[不限免]
    		designService.insertTmplPrice(param);
    		this.writeJSON("ok");
		} else {
			this.writeJSON("ng");
		}
	}
	// 删除模版价格
	public void delTmplPrice() throws Exception {
		Map<String, Object> session = ActionContext.getContext().getSession();
    	UserInfoDto user = (UserInfoDto)session.get("user");
    	if(user!=null && user.getUser_id()!=null) {
    		Map<String, Object> param = new HashMap<String, Object>();
    		param.put("priceIds", StringUtils.listToString2(StringUtils.stringToList2(ids)));
			param.put("update_by", user.getUser_id()+user.getUser_name());
			designService.deleteTmplPriceInfo(param);
    		this.writeJSON("ok");
    	} else {
    		this.writeJSON("ng");
    	}
	}

	// 获取组织信息
	public String getOrgInfoLst() throws Exception {

		Map<String, Object> param = new HashMap<String, Object>();
		param.put("state", 4);// 审核通过的组织
		orgInfoList = designService.selectOrgInfo(param);
		if(orgInfoList != null && orgInfoList.size()>0){
			// 添加空白项目
//			OrgInfoDto blankItem = new OrgInfoDto();
//			blankItem.setOrg_id(0L);
//			blankItem.setName("<未选择...>");
//			orgInfoList.add(0, blankItem);
			
			// 默认选中第一个
			orgInfoList.get(0).setSelected(true);// 无效！？？
		}
		return SUCCESS;
	}
	
	// 审核通过
	public void doChkOK() throws Exception {
		// ids: ","连接
		if (StringUtils.isNotBlank(ids)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	if(user!=null && user.getUser_id()!=null){
	    		List<Long> listId = StringUtils.stringToList2(ids);
		    	// update
	    		Map<String, Object> param = new HashMap<String, Object>();
				param.put("state", 32);
				param.put("ids", StringUtils.listToString2(listId));
				param.put("update_by", user.getUser_id());
				designService.updateDesignById(param);
				
				// 添加评审纪录
				Map<String, Object> insParam = new HashMap<String, Object>();
				insParam.put("design_id", StringUtils.listToString2(listId));// TODO
				insParam.put("state", 32);
				insParam.put("content", chkCont);
				insParam.put("reviewer", user.getUser_id());
				insParam.put("update_by", user.getUser_id());
				designService.insertReviewHis(insParam);
	    	}
		}
		this.writeJSON("ok");
	}
	// 审核失败
	public void doChkNG() throws Exception {
		// ids: ","连接
		if (StringUtils.isNotBlank(ids)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
	    	UserInfoDto user = (UserInfoDto)session.get("user");
	    	if(user!=null && user.getUser_id()!=null){
	    		List<Long> listId = StringUtils.stringToList2(ids);
		    	// update
	    		Map<String, Object> param = new HashMap<String, Object>();
				param.put("state", 42);
				param.put("ids", StringUtils.listToString2(listId));
				param.put("update_by", user.getUser_id());
				designService.updateDesignById(param);
				
				// 添加评审纪录
				Map<String, Object> insParam = new HashMap<String, Object>();
				insParam.put("design_id", StringUtils.listToString2(listId));// TODO
				insParam.put("state", 42);
				insParam.put("content", chkCont);
				insParam.put("reviewer", user.getUser_id());
				insParam.put("update_by", user.getUser_id());
				designService.insertReviewHis(insParam);
	    	}
		}
		this.writeJSON("ok");
	}
	
	
	/**	author 李琦	下架审核通过 
	 * 	1.修改state2 = 32二级审核通过
	 * 	2.插入复审记录
	 * @throws Exception
	 */
	public void doChk2OK() throws Exception {
		// ids: ","连接
		if (StringUtils.isNotBlank(ids)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
			UserInfoDto user = (UserInfoDto)session.get("user");
			if(user!=null && user.getUser_id()!=null){
				List<Long> listId = StringUtils.stringToList2(ids);
				// update
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("state2", 32);// 32二级审核通过
				param.put("ids", StringUtils.listToString2(listId));
				param.put("update_by", user.getUser_id());
				designService.updateDesignById(param);
				
				// 添加评审纪录
				Map<String, Object> insParam = new HashMap<String, Object>();
				insParam.put("design_id", StringUtils.listToString2(listId));// TODO
				insParam.put("state", 32);
				insParam.put("content", chkCont);
				insParam.put("reviewer", user.getUser_id());
				insParam.put("update_by", user.getUser_id());
				designService.insertReview2His(insParam);
			}
		}
		this.writeJSON("ok");
	}
	/** author 李琦 下架审核失败 ids: ","连接
	 */
	public void doChk2NG() throws Exception {
		if (StringUtils.isNotBlank(ids)) {
			Map<String, Object> session = ActionContext.getContext().getSession();
			UserInfoDto user = (UserInfoDto)session.get("user");
			if(user!=null && user.getUser_id()!=null){
				List<Long> listId = StringUtils.stringToList2(ids);
				// update
				Map<String, Object> param = new HashMap<String, Object>();
				param.put("state2", 42);// 42二级审核失败
				param.put("ids", StringUtils.listToString2(listId));
				param.put("update_by", user.getUser_id());
				designService.updateDesignById(param);
				
				// 添加评审纪录
				Map<String, Object> insParam = new HashMap<String, Object>();
				insParam.put("design_id", StringUtils.listToString2(listId));// TODO
				insParam.put("state", 42);
				insParam.put("content", chkCont);
				insParam.put("reviewer", user.getUser_id());
				insParam.put("update_by", user.getUser_id());
				designService.insertReview2His(insParam);
			}
		}
		this.writeJSON("ok");
	}
	
	// 获取关键词信息
	public String getKeywordLst(){
		if(keywordList == null){
			keywordList = new ArrayList<Object>();
		}
		keywordList.clear();
		
		Map<String, Object> param = new HashMap<String, Object>();
		if(designId!=null && Long.valueOf(designId)>0){
			param.put("design_id", designId);
		}
		List<KeywordInfoDto> kwList = designService.selectKeywordInfo(param);
		if(kwList != null && kwList.size()>0){
			Integer tmpType = kwList.get(0).getType();
			List<KeywordInfoDto> subList = new ArrayList<KeywordInfoDto>();
			
			// 按type分组
			for(int i=0; i<kwList.size(); i++){
				KeywordInfoDto info = kwList.get(i);
				
				if(info.getType() != tmpType){
					keywordList.add(subList);
					subList = new ArrayList<KeywordInfoDto>();
					
					tmpType = info.getType();
				}
				
				subList.add(info);
				
				if(i==kwList.size()-1){
					keywordList.add(subList);
				}
			}
		}

		return SUCCESS;
	}
	
	// 检索热门专题信息
	public String getTopicInfoLst() throws Exception {
		if(topicList == null){
			topicList = new ArrayList<Object>();
		}
		topicList.clear();
		
		Map<String, Object> param = new HashMap<String, Object>();
		if(designId!=null && Long.valueOf(designId)>0){
			param.put("design_id", designId);
		}
		param.put("type", topType);
		param.put("typeIds", StringUtils.listToString2(StringUtils.stringToList2(typeIds)));
		List<TopicInfoDto> stList = designService.selectTopicInfo(param);// 按use排序
		if(stList != null && stList.size()>0){
			Integer tmpUse = stList.get(0).getUse();
			List<TopicInfoDto> subList = new ArrayList<TopicInfoDto>();
			
			// 按use分组
			for(int i=0; i<stList.size(); i++){
				TopicInfoDto info = stList.get(i);
				
				if(info.getUse() != tmpUse){
					topicList.add(subList);
					subList = new ArrayList<TopicInfoDto>();
					
					tmpUse = info.getUse();
				}
				
				subList.add(info);
				
				if(i==stList.size()-1){
					topicList.add(subList);
				}
			}
		}

		return SUCCESS;
	}
	
	//get userdocInfo
	public String getDisUserDocInfo(){
		Map<String, Object> session = ActionContext.getContext().getSession();
		UserInfoDto user = (UserInfoDto)session.get("user");
		if(user!=null && user.getUser_id()!=null){
			HttpServletRequest request =ServletActionContext.getRequest();
			String pageNumber = request.getParameter("page");
    		String pageSize = request.getParameter("rows");
    		String disId = request.getParameter("disId");
    		if(disId!=null){
    			Map<String, Object> parm = new HashMap<String, Object>();
    			if(StringUtils.isNotEmpty(findDocId)){
    				parm.put("doc_id",findDocId);
    			}
    			if(StringUtils.isNotEmpty(findUserId)){
    				parm.put("user_id",findUserId);
    			}
    			if(StringUtils.isNotEmpty(findMobile)){
    				parm.put("mobile",findMobile);
    			}
				parm.put("disign_id", disId);
				Page page=designService.getDisUserDocInfo(parm, Integer.parseInt(pageNumber), Integer.parseInt(pageSize));
				userDocMap.put("total",page.getTotalCount());
				userDocMap.put("rows",page.getResult());
    		}
    	}
		return SUCCESS;
	}

	public DesignService getDesignService() {
		return designService;
	}

	public void setDesignService(DesignService designService) {
		this.designService = designService;
	}

	public DesignInfoDto getDesignInfo() {
		return designInfo;
	}

	public void setDesignInfo(DesignInfoDto designInfo) {
		this.designInfo = designInfo;
	}

	public List<DesignInfoDto> getDesignInfoList() {
		return designInfoList;
	}

	public void setDesignInfoList(List<DesignInfoDto> designInfoList) {
		this.designInfoList = designInfoList;
	}

	public String getDesignId() {
		return designId;
	}

	public void setDesignId(String designId) {
		this.designId = designId;
	}

	public String getIds() {
		return ids;
	}

	public void setIds(String ids) {
		this.ids = ids;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getFindTmplType() {
		return findTmplType;
	}

	public void setFindTmplType(String findTmplType) {
		this.findTmplType = findTmplType;
	}

	public String getFindPubFlg() {
		return findPubFlg;
	}

	public void setFindPubFlg(String findPubFlg) {
		this.findPubFlg = findPubFlg;
	}

	public String getFindTmplName() {
		return findTmplName;
	}

	public void setFindTmplName(String findTmplName) {
		this.findTmplName = findTmplName;
	}

	public String getFindTmplState() {
		return findTmplState;
	}

	public void setFindTmplState(String findTmplState) {
		this.findTmplState = findTmplState;
	}

	public String getFindOrg() {
		return findOrg;
	}

	public void setFindOrg(String findOrg) {
		this.findOrg = findOrg;
	}

	public HashMap<String, Object> getMapResult() {
		return mapResult;
	}

	public void setMapResult(HashMap<String, Object> mapResult) {
		this.mapResult = mapResult;
	}

	public String getTypeIds() {
		return typeIds;
	}

	public void setTypeIds(String typeIds) {
		this.typeIds = typeIds;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	public TgEgretInfoDto getTgEgretInfo() {
		return tgEgretInfo;
	}

	public void setTgEgretInfo(TgEgretInfoDto tgEgretInfo) {
		this.tgEgretInfo = tgEgretInfo;
	}

	public HashMap<String, Object> getMapResult4Review() {
		return mapResult4Review;
	}

	public void setMapResult4Review(HashMap<String, Object> mapResult4Review) {
		this.mapResult4Review = mapResult4Review;
	}

	public HashMap<String, Object> getMapResultTmplPrice() {
		return mapResultTmplPrice;
	}

	public void setMapResultTmplPrice(HashMap<String, Object> mapResultTmplPrice) {
		this.mapResultTmplPrice = mapResultTmplPrice;
	}

	public List<OrgInfoDto> getOrgInfoList() {
		return orgInfoList;
	}

	public void setOrgInfoList(List<OrgInfoDto> orgInfoList) {
		this.orgInfoList = orgInfoList;
	}

	public String getChkCont() {
		return chkCont;
	}

	public void setChkCont(String chkCont) {
		this.chkCont = chkCont;
	}

	public List<Object> getKeywordList() {
		return keywordList;
	}

	public void setKeywordList(List<Object> keywordList) {
		this.keywordList = keywordList;
	}

	public List<Object> getTopicList() {
		return topicList;
	}

	public void setTopicList(List<Object> topicList) {
		this.topicList = topicList;
	}

	public String getTopType() {
		return topType;
	}

	public void setTopType(String topType) {
		this.topType = topType;
	}

	public String getStIds() {
		return stIds;
	}

	public void setStIds(String stIds) {
		this.stIds = stIds;
	}

	public String getItemIdForItems() {
		return itemIdForItems;
	}

	public void setItemIdForItems(String itemIdForItems) {
		this.itemIdForItems = itemIdForItems;
	}

	public TmplPriceInfoDto getTmplPriceInfo() {
		return tmplPriceInfo;
	}

	public void setTmplPriceInfo(TmplPriceInfoDto tmplPriceInfo) {
		this.tmplPriceInfo = tmplPriceInfo;
	}

	public String getFindTmplId() {
		return findTmplId;
	}

	public void setFindTmplId(String findTmplId) {
		this.findTmplId = findTmplId;
	}

	public String getFindItemId() {
		return findItemId;
	}

	public void setFindItemId(String findItemId) {
		this.findItemId = findItemId;
	}

	public String getVip() {
		return vip;
	}

	public void setVip(String vip) {
		this.vip = vip;
	}

	public String getFindVip() {
		return findVip;
	}

	public void setFindVip(String findVip) {
		this.findVip = findVip;
	}

	public String getSrcUrl() {
		return srcUrl;
	}

	public void setSrcUrl(String srcUrl) {
		this.srcUrl = srcUrl;
	}

	public HashMap<String, Object> getUserDocMap() {
		return userDocMap;
	}

	public void setUserDocMap(HashMap<String, Object> userDocMap) {
		this.userDocMap = userDocMap;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	public String getFindDocId() {
		return findDocId;
	}
	public void setFindDocId(String findDocId) {
		this.findDocId = findDocId;
	}
	public String getFindUserId() {
		return findUserId;
	}
	public void setFindUserId(String findUserId) {
		this.findUserId = findUserId;
	}

	public String getFindMobile() {
		return findMobile;
	}
	public void setFindMobile(String findMobile) {
		this.findMobile = findMobile;
	}
	
	
	
	// 获取 一键秀模板套餐价格 
	private List<Object> tgMeal;// 模板套餐
	private String tgDesignId;// 模板ID
	public String getYjxTgPriceMealInfo(){
		if (tgMeal == null){
			tgMeal = new ArrayList<Object>();
		}
		tgMeal.clear();// 清空
		
		Map<String, Object> param = new HashMap<String, Object>();
		if(tgDesignId!=null && Long.valueOf(tgDesignId)>0){
			param.put("design_id", tgDesignId); // 
		}
		List<YjxPriceInfoDto> priList = designService.selectPriceInfo(param);
		if(priList != null && priList.size()>0){
			Long tmpType = priList.get(0).getPrice_type();
			List<YjxPriceInfoDto> subList = new ArrayList<YjxPriceInfoDto>();// 判断放到一个数组里面
			// 按type分组
			for(int i=0; i<priList.size(); i++){ 
				
				YjxPriceInfoDto info = priList.get(i);
				if(info.getPrice_type()!= tmpType){
					tgMeal.add(subList);
					subList = new ArrayList<YjxPriceInfoDto>();
					tmpType = info.getPrice_type();
				}  
				String st = "其它";
				//价格类型: 2[去水印订单],4[秒杀订单],8[vip订单],16[待定]
				switch(Integer.parseInt(tmpType.toString())){
				case 2 : st = "去水印订单";break; 
				case 4 : st = "秒杀订单";break; 
				case 8 : st = "vip订单";break; 
				case 16 : st = "待定";break; 
				}
				info.setType_name(st);
				subList.add(info);
				if(i==priList.size()-1){
					tgMeal.add(subList);
				}
			}
		}
		return SUCCESS;
	}
	public List<Object> getTgMeal() {
		return tgMeal;
	}
	public void setTgMeal(List<Object> tgMeal) {
		this.tgMeal = tgMeal;
	}
	public String getTgDesignId() {
		return tgDesignId;
	}

	public void setTgDesignId(String tgDesignId) {
		this.tgDesignId = tgDesignId;
	}

	// 给模板添加 去水印套餐价格
	public void addPriceRInfo() throws Exception{
		Map<String, Object> session = ActionContext.getContext().getSession();
		UserInfoDto user = (UserInfoDto) session.get("user");
		HttpServletRequest request = ServletActionContext.getRequest();
		String uitemId = request.getParameter("uItemId"); // 统计模板ID
		String price_id = request.getParameter("price_id");
		if (user != null && user.getUser_id() != null && StringUtils.isNotEmpty(uitemId)) {
			Map<String, Object> parm = new HashMap<String, Object>();
			String[] ids = StringUtils.str2Array(price_id);
			parm.put("update_by",user.getUser_id());
			parm.put("uni_item_id",uitemId);
			boolean b = false;
			b = designService.delPriceRInfo(parm);
			if (b){ // 先删除 判断是否删除成功
				for (String id : ids) {
					parm.put("price_id", id);
					b = designService.addPriceRInfo(parm);
				}
				if (b){
					this.writeJSON("ok");
				} else {
					this.writeJSON("no");
				}
			} else {
			   this.writeJSON("no");
			}
		} else {
			this.writeJSON("no");
		}
	}
	
}
